<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
 <%@ page import="model.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Patient Details</title>
<link rel="icon" type="image/png" href="images/logo-favicon.png" />
<link rel="stylesheet" type="text/css" href="css/standard.css" />
<link rel="stylesheet" type="text/css" href="css/banner.css" />
<link rel="stylesheet" type="text/css" href="css/results.css" />
<link rel="stylesheet" type="text/css" href="css/patient.css" />
</head>
<body>
	<%@ include file="banner.jsp" %>
	<div id="content">
	<% 
		Patient p= (Patient)session.getAttribute("patient");
	%>

	<h1 id="title">&nbsp;Patient: &nbsp; &nbsp;<%=p.getName()%></h1>	
	
	<div id="combinedArea">
	<div id ="patientArea">
	<table class ="patientInfo">
		<tr>
			<th>Address:</th>
			<% 
			String addr = p.getAddress();
			if (addr.length() != 0)
			{ 
			%>
				<td>
				<%=addr%><br/>
				<%=p.getCity()%>, <%=p.getState()%> <%=p.getPostalCode()%> <br/>
				<%=p.getCountry()%>
				</td>
			<% } else {%>
				<td>
				<%=p.getCountry()%>
				</td>
			<% } %>
		</tr>
		<tr>
			<th>Blood Type:</th>
			<td><%=p.getBloodType()%></td>
		</tr>
		<tr>
			<th>Date of Birth:</th>
			<td><%=p.getDOB()%></td>
		</tr>
		<tr>
			<th>Gender:</th>
			<td><%= p.getGender().equals("M")? "Male": "Female" %></td>
		</tr>
		<tr>
			<th>Insurance:</th>
			<td><%=p.getInsurer()%></td>
		</tr>
		<tr>
			<th>Race:</th>
			<td><%=p.getRace()%></td>
		</tr>
		<tr>
			<th>Religion:</th>
			<td><%=p.getReligion()%></td>
		</tr>
	</table>
 	</div>
 
		<div id ="allergyArea">
		<%! @SuppressWarnings("unchecked") %>
		<% 
		List<String> allergies= (List<String>)session.getAttribute("allergies");
		 if (!allergies.isEmpty())
		 {
	%>	
	 
			<table class ="visits"> 
				<caption>Allergies</caption>
				<tr>
					<th>Allergy</th>
				</tr>
	
				<% 
	 			for (String al: allergies)
	 			{
				%>
		
					<tr>
	 					<td><%= al %></td>
					</tr>
			 <% }%>
			</table>
		<%}%>
		</div>
		
		<div id="medsArea">
	<% 
		 List<List<String>> medicationsRow= (List<List<String>>)session.getAttribute("medications");
		 if (!medicationsRow.isEmpty())
		 {
	%>	
	 
			<table class ="visits"> 
				<caption>Medications</caption>
				<tr>
					<th>Name</th>
					<th>Dosage</th>
				</tr>
	
				<% 
	 			for (List<String> medicationsCol: medicationsRow)
	 			{
				%>
		
					<tr>
	
						<% 	for(String medsInfo: medicationsCol)
							{
						%>
	
	 						<td><%= medsInfo %></td>
	  			  		  <%} %> 
	
					</tr>
			 <% }%>
			</table>
		<%}%>
		</div>
		
		
		</div>
		<div id ="clear"></div>
		
		<% 
		List<List<String>> visitsRow= (List<List<String>>)session.getAttribute("visits");
		 if (!visitsRow.isEmpty())
		 {
	%>	
	 
			<table class ="visits"> 
				<caption>Visits</caption>
				<tr>
					<th>Date</th>
					<th>Reason</th>
					<th>Doctor</th>
					<th>Specialization</th>
				</tr>
	
				<% 
	 			for (List<String> visitsCol: visitsRow)
	 			{
				%>
					<tr>
	
						<% 	for(String visitInfo: visitsCol)
							{
						%>
	 						<td><%= visitInfo %></td>
	  			  		  <%} %> 
	
					</tr>
			 <% }%>
			</table>
		<%}%>
	<br/>
	&nbsp;<a href="index.jsp">Search Again</a>
</div>
</body>
</html>